home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
arexx
/
gtlclndx.lha
/
GetLocalIndex.rx
< prev
Wrap
Text File
|
1996-04-01
|
9KB
|
248 lines
/*
** $VER: GetLocalIndex.rx 0.3 (1.4.96)
**
** ARexx script to create aminet style index files
**
** To use this script, change the following 4 variables to your
** own settings: MainDir, HostAddress, LocalFile, RecentFile.
**
** This script requires rexxsupport.library to run.
**
** Written by Edwin H. Bielawski (ehb@draco.prima.ruhr.de)
**
** Status: FREEWARE
**
*/
MainDir = 'FTPC:aminet' /* your aminet directory */
HostAddress = 'draco.prima.ruhr.de [193.141.111.197]' /* Host name and IP address */
LocalFile = 'LOCAL' /* Name (file part) of the index file to create */
RecentFile = 'RECENT' /* Name (file part) of the recent file to create */
If ~Show('L',"rexxsupport.library") Then AddLib("rexxsupport.library",0,-30,0)
Directory = MainDir
Say 'Create '||LocalFile||' for '||Directory
Files = ShowDir(Directory, 'D', ';')
If Open(WriteHandle,'T:LOCAL.0','WRITE') Then Do
WriteLn(WriteHandle,'')
CurrentFile = ''
Do Until (CurrentFile = '')
Parse VAR Files CurrentFile';'Files
If CurrentFile ~= '' Then Do
CALL GetLocalSub(Directory, CurrentFile, LocalFile)
Line = Directory||'/'||CurrentFile||'/'||LocalFile
WriteLn(WriteHandle,Line)
End
End
Close(WriteHandle)
Address COMMAND "Sort T:LOCAL.0 TO T:LOCAL.1"
Destination = Directory||'/'||LocalFile
If Open(WriteHandle,Destination,'WRITE') Then Do
WriteLn(WriteHandle,'| Local Aminet index on '||Date('N'))
WriteLn(WriteHandle,'| The list is sorted by directory and file name')
WriteLn(WriteHandle,'| This site is '||HostAddress||'.')
WriteLn(WriteHandle,'| Age measured in weeks before creation of this index.')
WriteLn(WriteHandle,'|')
WriteLn(WriteHandle,'|File Dir Size Age Description')
WriteLn(WriteHandle,'|----------------- --- ---- --- -----------')
If Open(ReadHandle,'T:LOCAL.1','READ') Then Do
Do While ~eof(ReadHandle)
CurrentLine = Compress(ReadLn(ReadHandle),'0d'x)
If CurrentLine ~= '' Then Do
If Open(TempReadHandle,CurrentLine,'READ') Then Do
Line = ReadLn(TempReadHandle)
Line = ReadLn(TempReadHandle)
Do While ~eof(TempReadHandle)
Line = ReadLn(TempReadHandle)
If Line ~= '' Then WriteLn(WriteHandle,Line)
End
Close(TempReadHandle)
End
End
End
End
Close(WriteHandle)
Close(ReadHandle)
End
End
If Open(WriteHandle,MainDir||'/'||RecentFile,'WRITE') Then Do
WriteLn(WriteHandle,'| Recent uploads to '||HostAddress||' on '||Date('N'))
WriteLn(WriteHandle,'|')
WriteLn(WriteHandle,'|File Dir Size Description')
WriteLn(WriteHandle,'|----------------- --- ---- -----------')
If Open(ReadHandle,MainDir||'/'||LocalFile,'READ') Then Do
Do While ~eof(ReadHandle)
Line = ReadLn(ReadHandle)
If Left(Line,1) ~= '|' Then Do
If SubStr(Line,36,3) = ' 0' Then Do
NewLine = SubStr(Line,1,35)||SubStr(Line,40)
WriteLn(WriteHandle,NewLine)
End
End
End
Close(ReadHandle)
End
Close(WriteHandle)
End
ADDRESS COMMAND "Delete >NIL: T:LOCAL.?"
Exit
/* ------------------------------------------------- */
GetLocalSub: Procedure
Parse ARG StartDir,SubDir,LocalFile
If SubDir ~= '' Then Do
Directory = StartDir||'/'||SubDir
Say 'Create '||LocalFile||' for '||Directory
Files = ShowDir(Directory, 'D', ';')
If Open(WriteHandle1,'T:LOCAL.2','WRITE') Then Do
WriteLn(WriteHandle1,'')
CurrentFile = ''
Do Until (CurrentFile = '')
Parse VAR Files CurrentFile';'Files
If CurrentFile ~= '' Then Do
CALL GetLocalSubSub(StartDir, SubDir||'/'||CurrentFile, LocalFile)
Line = Directory||'/'||CurrentFile||'/'||LocalFile
WriteLn(WriteHandle1,Line)
End
End
Close(WriteHandle1)
Address COMMAND "Sort T:LOCAL.2 TO T:LOCAL.3"
Destination = Directory||'/'||LocalFile
If Open(WriteHandle1,Destination,'WRITE') Then Do
Message = '| Contents of the directory '||SubDir
If exists(Directory||'/.message') Then Do
If Open(ReadHandle,Directory||'/.message','READ') Then Do
Message = ReadLn(ReadHandle)
Close(ReadHandle)
End
Message = '| Contents of the directory '||Message
Message = Compress(Message,'0d'x)
End
WriteLn(WriteHandle1,Message)
WriteLn(WriteHandle1,'|------------------------------------------------')
If Open(ReadHandle,'T:LOCAL.3','READ') Then Do
Do While ~eof(ReadHandle)
CurrentLine = Compress(ReadLn(ReadHandle),'0d'x)
If CurrentLine ~= '' Then Do
If Open(TempReadHandle,CurrentLine,'READ') Then Do
Line = ReadLn(TempReadHandle)
Line = ReadLn(TempReadHandle)
Do While ~eof(TempReadHandle)
Line = ReadLn(TempReadHandle)
If Line ~= '' Then WriteLn(WriteHandle1,Line)
End
Close(TempReadHandle)
End
End
End
End
Close(WriteHandle1)
Close(ReadHandle)
End
End
End
Return(0)
/* ------------------------------------------------- */
GetLocalSubSub: Procedure
Parse ARG StartDir,SubDir,LocalFile
If SubDir ~= '' Then Do
Directory = StartDir||'/'||SubDir
DOIT = 0
If ~exists(Directory||'/'||LocalFile) Then DOIT = 1
Else Do
FileState = StateF(Directory||'/'||LocalFile)
Parse VAR FileState Dummy1 Size Dummy3 Dummy4 F_Tag F_Minuten Dummy5
If Size > 100 Then DOIT = 1
Else Do
DirState = StateF(Directory)
Parse VAR DirState Dummy1 Dummy2 Dummy3 Dummy4 D_Tag D_Minuten Dummy5
If F_Tag < D_Tag Then DOIT = 1
Else If F_Tag = D_Tag Then If F_Minuten < D_Minuten Then DOIT = 1
End
End
If DOIT Then Do
Say 'Create '||LocalFile||' for '||Directory
Files = ShowDir(Directory, 'f', ';')
If Open(WriteHandle2,'T:LOCAL.4','WRITE') Then Do
WriteLn(WriteHandle2,'')
CurrentFile = ''
Do Until (CurrentFile = '')
Parse VAR Files CurrentFile';'Files
If CurrentFile ~= '' Then Do
UpperCurrentFile = Upper(CurrentFile)
If UpperCurrentFile ~= 'LOCAL' Then Do
If Left(UpperCurrentFile,5) ~= 'INDEX' Then Do
If Left(UpperCurrentFile,1) ~= '.' Then Do
If Right(UpperCurrentFile,6) ~= 'README' Then Do
CurrentLine = Left(CurrentFile,19)||Left(SubDir,10)
FileState = StateF(Directory||'/'||CurrentFile)
Parse VAR FileState Dummy1 FileSize Dummy2 Dummy3 F_Tag Dummy4
If FileSize < 1000 Then CurrentLine = CurrentLine||Right(FileSize,5)
Else Do
FileSize = FileSize%1000
If FileSize < 1000 Then CurrentLine = CurrentLine||Right(FileSize,4)||'K'
Else Do
FileSizeRest = Left(Right((FileSize//1000),3,'0'),1)
FileSize = FileSize%1000
CurrentLine = CurrentLine||Right(FileSize,2)||'.'||FileSizeRest||'M'
End
End
CurrentLine = CurrentLine||Right((Date('I')-F_Tag+1)%7,4)
CheckFile = CurrentFile
ReadMeFile = Directory||'/'||CheckFile||'.readme'
Do Until (CheckFile='' | exists(ReadMeFile))
CheckFile = Left(CheckFile,Length(CheckFile)-1)
ReadMeFile = Directory||'/'||CheckFile||'.readme'
End
If CheckFile ~='' Then Do
If Open(ReadHandle,ReadMeFile,'READ') Then Do
Message = ReadLn(ReadHandle)
Parse VAR Message 'Short:' ReadMe
CurrentLine = CurrentLine||' '||Strip(ReadMe)
Close(ReadHandle)
End
End
WriteLn(WriteHandle2,CurrentLine)
End
End
End
End
End
End
Close(WriteHandle2)
Address COMMAND "Sort T:LOCAL.4 TO T:LOCAL.5"
If Open(WriteHandle2,Directory||'/'||LocalFile,'WRITE') Then Do
Message = '| Contents of the directory '||SubDir
If exists(Directory||'/.message') Then Do
If Open(ReadHandle,Directory||'/.message','READ') Then Do
Message = ReadLn(ReadHandle)
Close(ReadHandle)
End
Message = '| Contents of the directory '||Message
Message = Compress(Message,'0d'x)
End
WriteLn(WriteHandle2,Message)
WriteLn(WriteHandle2,'|------------------------------------------------')
If Open(ReadHandle,'T:LOCAL.5','READ') Then Do
Do While ~eof(ReadHandle)
CurrentLine = Compress(ReadLn(ReadHandle),'0d'x)
If CurrentLine ~= '' Then WriteLn(WriteHandle2,CurrentLine)
End
End
Close(ReadHandle)
Close(WriteHandle2)
End
End
End
End
return(0)